#include<bits/stdc++.h>
using namespace std;
#define int long long

int begin_postion[] = {0, 1, 21, 101, 2101, 10101, 210101, 1010101};
int numbers[8];


void getNumbers() {

	numbers[1] = 5;

	for (int i = 2; i <= 7; i++) {
		// 自己写开，切勿模仿
		numbers[i] = i % 2 ? 5 * (numbers[i - 1] + numbers[i - 2]) : (4 * numbers[i - 1]);
	}

	for (int i = 2 ; i <= 7; i++) {
		numbers[i] += numbers[i - 1];
	}
}


int getDigit(int x) {
	int cnt = 0;
	while (x) {
		cnt++;
		x /= 10;
	}
	return cnt;
}


bool check(int x) {
	bool flag = 1;
	while (x) {
		if (x % 2 != flag)
			return false;
		flag ^= 1;
		x /= 10;
	}
	return true;
}


signed main() {
//	system("start https://www.lanqiao.cn/problems/19709/learning/");

	getNumbers();

	int n;
	cin >> n;

	int k = getDigit(n);
	int ans = numbers[k - 1];
	for (int i = begin_postion[k]; i <= n; i++) {
		if (check(i))	ans++;
	}
	cout << ans;

	return 0;
}
